import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/Index.vue'
import Home from '../components/index/home'


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Index',
    redirect: '/index',
    component: Index,
    meta: {
      title: "首页"
    },
    children: [
      // 首页路由
      {
        path: '/index',
        name: 'Home',
        component: Home,
        meta: {
          title: "首页"
        },
      },
      // 用户管理的相关路由
      {
        path: 'user',
        name: 'User',
        redirect: '/user/userlist',
        component: () => import(/* webpackChunkName: "User" */ '../components/user/user'),
        meta: {
          title: "用户管理"
        },
        children: [
          {
            path: 'userlist',
            name: 'Userlist',
            meta: {
              title: "用户列表"
            },
            component: () => import(/* webpackChunkName: "userlist" */ '../components/user/userList.vue')
          },
          {
            path: 'adduser',
            name: 'Adduser',
            meta: {
              title: "添加用户"
            },
            component: () => import(/* webpackChunkName: "adduser" */ '../components/user/adduser.vue')
          },
          {
            path: 'admin',
            name: 'Admin',
            meta: {
              title: "权限管理"
            },
            component: () => import(/* webpackChunkName: "admin" */ '../components/user/admin.vue')
          }
        ]
      },
      // 商品相关路由
      {
        path: 'product',
        name: 'Product',
        redirect: '/product/protype',
        meta: {
          title: "商品管理"
        },
        component: () => import(/* webpackChunkName: "admin" */ '../components/product/product.vue'),
        children: [
          {
            path: 'hostpro',
            name: 'HostPro',
            meta: {
              title: "热门商品"
            },
            component: () => import(/* webpackChunkName: "HostPro" */ '../components/product/hostPro.vue')
          },
          {
            path: 'protype',
            name: 'ProType',
            meta: {
              title: "类别管理"
            },
            component: () => import(/* webpackChunkName: "proType" */ '../components/product/proType.vue')
          },
          {
            path: 'prolist',
            name: 'proList',
            meta: {
              title: "商品列表"
            },
            component: () => import(/* webpackChunkName: "proList" */ '../components/product/proList.vue')
          },
          {
            path: 'addpro',
            name: 'addPro',
            meta: {
              title: "添加商品"
            },
            component: () => import(/* webpackChunkName: "addpro" */ '../components/product/addPro.vue')
          },
        ]
      },
    ]
  },
  // 登录路由
  {
    path: '/login',
    name: 'Login',
    component: () => import(/* webpackChunkName: "about" */ '../views/Login.vue')
  },
  // 测试文件上传
  {
    path: '/add',
    component: () => import(/* webpackChunkName: "about" */ '../views/addpro.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
